using System;
using System.Collections.Generic;
using System.ComponentModel;
using Microsoft.Ccr.Core;
using Microsoft.Dss.Core;
using Microsoft.Dss.Core.Attributes;
using Microsoft.Dss.ServiceModel.Dssp;
using Microsoft.Dss.ServiceModel.DsspServiceBase;
using W3C.Soap;
using submgr = Microsoft.Dss.Services.SubscriptionManager;
using ds = Microsoft.Dss.Services.Directory;
using referee = HCC.Robotics.HCCRefereeModule.Proxy;
using Microsoft.Dss.Core.DsspHttp;
using System.Threading;
using HCC.Robotics.HCCRefereeModule.Proxy;

namespace HCC.Robotics.HCCPlayerModule
{
    public sealed class Contract
    {
        [DataMember]
        public const string Identifier = "http://www.hccrobotica.nl/2011/09/hccplayermodule.html";
    }

    [DataContract]
    public class HCCPlayerModuleState
    {
        [DataMember]
        public RefereeConfig Configuration { get; set; }
    }

    [ServicePort]
    public class HCCPlayerModuleOperations : PortSet<DsspDefaultLookup, DsspDefaultDrop, Get, HttpGet, Subscribe, BallPositionUpdate, PlayersPositionsUpdate, FieldDataUpdate, StateDataUpdate>
    {
    }

    public class Get : Get<GetRequestType, PortSet<HCCPlayerModuleState, Fault>>
    {
        public Get()
        {
        }

        public Get(GetRequestType body)
            : base(body)
        {
        }

        public Get(GetRequestType body, PortSet<HCCPlayerModuleState, Fault> responsePort)
            : base(body, responsePort)
        {
        }
    }

    public class Subscribe : Subscribe<SubscribeRequestType, PortSet<SubscribeResponseType, Fault>>
    {
        public Subscribe()
        {
        }

        public Subscribe(SubscribeRequestType body)
            : base(body)
        {
        }

        public Subscribe(SubscribeRequestType body, PortSet<SubscribeResponseType, Fault> responsePort)
            : base(body, responsePort)
        {
        }
    }

    #region RefereeConfig

    [DataContract]
    public class RefereeConfig
    {
        [DataMember]
        public int Port { get; set; }
        [DataMember]
        public String Host { get; set; }
        [DataMember]
        public referee.Team TeamColor { get; set; }
        private string _version = "1.0.0";
        [DataMember]
        public string Version
        {
            get { return _version; }
            set { _version = "1.0.0"; }
        }
    }

    #endregion

    #region StateDataUpdate

    public class StateDataUpdate : Update<StateDataUpdateRequest, PortSet<DefaultUpdateResponseType, Fault>>
    {
        public StateDataUpdate()
        {
        }
        public StateDataUpdate(StateDataClass gamedata)
            : base(new StateDataUpdateRequest(gamedata))
        {
        }
    }

    [DataContract]
    public class StateDataUpdateRequest
    {
        public StateDataUpdateRequest()
        { }
        public StateDataUpdateRequest(StateDataClass gamestatedata)
        {
            GameStateData = gamestatedata;
        }
        [DataMember]
        public StateDataClass GameStateData { get; set; }
    }

    [DataContract]
    public class StateDataClass
    {
        [DataMember]
        public bool Player1Active { get; set; }
        [DataMember]
        public bool Player2Active { get; set; }
        [DataMember]
        public bool Oponent1Active { get; set; }
        [DataMember]
        public bool Oponent2Active { get; set; }
        // ID: 359
        [DataMember]
        public bool ScoreInRightGoal { get; set; }
        // ID: 359
    }

    #endregion

    #region FieldData

    public class FieldDataUpdate : Update<FieldDataUpdateRequest, PortSet<DefaultUpdateResponseType, Fault>>
    {
        public FieldDataUpdate()
        {
        }
        public FieldDataUpdate(FieldDataClass fielddata)
            : base(new FieldDataUpdateRequest(fielddata))
        {
        }
    }

    [DataContract]
    public class FieldDataUpdateRequest
    {
        public FieldDataUpdateRequest()
        { }
        public FieldDataUpdateRequest(FieldDataClass fielddata)
        {
            FieldData = fielddata;
        }
        [DataMember]
        public FieldDataClass FieldData { get; set; }
    }

    #endregion

    #region BallPositionUpdate

    [DataContract]
    public class BallPosition : Position
    {
    }

    public class BallPositionUpdate : Update<BallPositionUpdateRequest, PortSet<DefaultUpdateResponseType, Fault>>
    {
        public BallPositionUpdate()
        {
        }
        public BallPositionUpdate(BallPosition position)
            : base(new BallPositionUpdateRequest(position))
        {
        }
    }

    [DataContract]
    public class BallPositionUpdateRequest
    {
        public BallPositionUpdateRequest()
        {
        }
        public BallPositionUpdateRequest(BallPosition position)
        {
            BallPosition = position;
        }
        [DataMember]
        public BallPosition BallPosition { get; set; }
    }

    #endregion

    #region PlayersUpdate

    [DataContract]
    public class PlayerPosition : Position
    {
        [DataMember]
        public int Heading { get; set; }
    }

    [DataContract]
    public class PlayersPositions
    {
        [DataMember]
        public PlayerPosition Player1 { get; set; }
        [DataMember]
        public PlayerPosition Player2 { get; set; }
        [DataMember]
        public PlayerPosition Oponent1 { get; set; }
        [DataMember]
        public PlayerPosition Oponent2 { get; set; }
    }

    public class PlayersPositionsUpdate : Update<PlayersPositionsUpdateRequest, PortSet<DefaultUpdateResponseType, Fault>>
    {
        public PlayersPositionsUpdate()
        {
        }
        public PlayersPositionsUpdate(PlayersPositions positions)
            : base(new PlayersPositionsUpdateRequest(positions))
        {
        }
    }

    [DataContract]
    public class PlayersPositionsUpdateRequest
    {
        public PlayersPositionsUpdateRequest()
        {
        }
        public PlayersPositionsUpdateRequest(PlayersPositions positions)
        {
            PlayersPositions = positions;
        }
        [DataMember]
        public PlayersPositions PlayersPositions { get; set; }
    }

    #endregion
}


